From d4ca1c16e2867c461b3a9f37797d3234bffe56c9 Mon Sep 17 00:00:00 2001 From: "smh22@labyrinth.cl.cam.ac.uk" Date: Thu, 13 Nov 2003 10:57:10 +0000 Subject: [PATCH] bitkeeper revision 1.596.1.2 (3fb36386_diWp9iTBJCjk8zK8bRIEw) tweaks --- .../arch/xeno/drivers/block/xl_block.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/xenolinux-2.4.22-sparse/arch/xeno/drivers/block/xl_block.c b/xenolinux-2.4.22-sparse/arch/xeno/drivers/block/xl_block.c index 14c14053e0..23f445515c 100644 --- a/xenolinux-2.4.22-sparse/arch/xeno/drivers/block/xl_block.c +++ b/xenolinux-2.4.22-sparse/arch/xeno/drivers/block/xl_block.c @@ -69,10 +69,23 @@ int xenolinux_block_open(struct inode *inode, struct file *filep) short xldev = inode->i_rdev; struct gendisk *gd = xldev_to_gendisk(xldev); xl_disk_t *disk = xldev_to_xldisk(inode->i_rdev); + short minor = MINOR(xldev); + + if(!gd->part[minor].nr_sects) { + /* Device either doesn't exist, or has zero capacity; we use + a few cheesy heuristics to return the relevant error code */ + if(disk->capacity || (minor & (gd->max_p - 1))) { + // we have a real device, but no such partition, or we just + // have a partition number so guess this is the problem + return -ENXIO; // no such device or address + } else if (gd->flags[minor >> gd->minor_shift] & GENHD_FL_REMOVABLE) { + // this is a removable device => assume that media is missing + return -ENOMEDIUM; // media not present (this is a guess) + } else + // just go for the general 'no such device' error + return -ENODEV; // no such device + } - /* Don't allow open if device doesn't exist :-) */ - if(!gd->part[MINOR(xldev)].nr_sects) - return -ENXIO; // no such device disk->usage++; DPRINTK("xenolinux_block_open\n"); -- 2.30.2